package com.rcklos.NettyLentMe.config;

/**
 * @IMServerConfig
 * IM服务器主要配置
 * 后续应该使用.ini文件置于目录中与程序独立，应对分布式开发
 */
public class IMServerConfig {
    public static int PORT = 8080; // 端口号
    public static int SERVER_ID = 0B00000001; // id名称标识
    public static int MAX_CLIENT_COUNT = Integer.MAX_VALUE; // 最大客户端连接数量， 默认不受限制
    public static int PROTOCOL_VERSION = 0x02; // 协议版本号
    public static String INI_FILE_PATH = "";

    private static IMServerConfig instance;

    public static IMServerConfig getInstance() {
        if( instance == null ){
            synchronized (IMServerConfig.class){
                instance = loadConfig(INI_FILE_PATH);
            }
        }
        return instance;
    }

    private int port;
    private int server_id;
    private int max_client_count;
    private int protocol_version;

    private IMServerConfig(int port, int server_id, int max_client_count, int protocol_version) {
        this.port = port;
        this.server_id = server_id;
        this.max_client_count = max_client_count;
        this.protocol_version = protocol_version;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getServer_id() {
        return server_id;
    }

    public void setServer_id(int server_id) {
        this.server_id = server_id;
    }

    public int getMax_client_count() {
        return max_client_count;
    }

    public void setMax_client_count(int max_client_count) {
        this.max_client_count = max_client_count;
    }

    public int getProtocol_version() {
        return protocol_version;
    }

    public void setProtocol_version(int protocol_version) {
        this.protocol_version = protocol_version;
    }

    private static IMServerConfig loadConfig(String file_path){
        // ...
        return null;
    }
}
